var host = '你自己的本地IP或服务器域名';
var bald_url = host +'/rest/bald/merge';
var poster_url = host +'/rest/poster/v1/generate';
var poster_image_url = host + '/rest/poster/v2/generate';
/**
 * 秃头
 * @param file 图片
 */
let baldRequest = (file, callback) => {
  //发送接口请求
  wx.uploadFile({
    url: bald_url,
    filePath: file,
    header: {
      'content-type': 'multipart/form-data'
    },
    name: 'file',
    formData: {
      'version': '2'
    },
    method: 'POST',
    success: function (res) {
      callback.success(res.data)
    },
    fail: function (res) {
      if (callback.fail)
        callback.fail()
    }
  })
}
/**
 * 海报
 * @param file 图片
 */
let posterRequest = (file, avatarUrl, nickName, callback) => {
  //发送接口请求
  wx.uploadFile({
    url: poster_url,
    filePath: file,
    header: {
      'content-type': 'multipart/form-data'
    },
    name: 'file',
    formData: {
      'version': '2',
      'nickName': nickName,
      'avatarUrl': avatarUrl
    },
    method: 'POST',
    success: function (res) {
      callback.success(res.data)
    },
    fail: function (res) {
      if (callback.fail)
        callback.fail()
    }
  })
}
/**
 * 海报ByBase64
 * @param file 图片
 */
let posterRequestByBase64 = (image,avatarUrl,nickName, jobNum,callback) => {
  //发送接口请求
  wx.request({
    url: poster_image_url,
    method:'POST',
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    data: {
      'version': '2',
      'nickName': nickName,
      'avatarUrl': avatarUrl,
      'image': image,
      'jobNum':jobNum
    },
    success: function (res) {
      callback.success(res.data)
    },
    fail: function (res) {
      if (callback.fail)
        callback.fail()
    }
  })
}
/** 暴露出去 */
module.exports = {
  /** 暴露出去方法 */
  baldRequest: baldRequest,
  posterRequest: posterRequest,
  posterRequestByBase64: posterRequestByBase64
}
